package com.jarvis.hospital.patient.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jarvis.hospital.R;
import com.jarvis.hospital.patient.model.MessageModel;

import java.util.List;

/**
 * Created by jarvis.liu on 9/12/2016.
 */
public class MessageMainAdapter extends BaseQuickAdapter<MessageModel> {
    public MessageMainAdapter(int layoutResId, List<MessageModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MessageModel messageModel) {
        ImageView iv_avatar = baseViewHolder.getView(R.id.iv_avatar);
        ImageView img_unread = baseViewHolder.getView(R.id.img_unread);
        TextView tv_value = baseViewHolder.getView(R.id.tv_value);
        TextView tv_time = baseViewHolder.getView(R.id.tv_time);
        TextView tv_name = baseViewHolder.getView(R.id.tv_name);
        tv_name.setText(messageModel.getReceiveName());
        tv_value.setText(messageModel.getMsgContent());
        tv_time.setText(messageModel.getSendTime());
        if("1".equals(messageModel.getIsRead())){
            img_unread.setVisibility(View.INVISIBLE);
        }else {
            img_unread.setVisibility(View.VISIBLE);
        }
        Glide.with(mContext)
                .load(messageModel.getReceiverHeadImg())
                .error(R.mipmap.ic_launcher)
                .into(iv_avatar);
    }
}
